package com.ggqq.day316;

import java.util.Arrays;
import java.util.LinkedList;

public class TanXin {
    public static  void main(String[] args){
        int[][] matrix ={{7,0},{4,4},{7,1},{5,0},{6,1},{5,2}};
        TanXin tanXin = new TanXin();
        System.out.println(tanXin.reconstructQueue(matrix));

    }
    public int[][] reconstructQueue(int[][] people){
        Arrays.sort(people,(o1,o2) -> o1[0]==o2[0] ? o1[1]-o2[1] : o2[0]-o1[0] );//排序
        LinkedList<int[]> list = new LinkedList<>();
        for(int[] i: people){
            list.add(i[1],i);
        }
        return  list.toArray(new int[list.size()][2]);
    }

}
